﻿using System;

namespace TravisCI.Models
{
    public class Job
    {
        private string auth_token;

        public Job(string auth_token)
        {
            this.auth_token = auth_token;
        }

        public long Id { get; set; }
        public string Result { get; set; }
        public string Number { get; set; }
        public string Env { get; set; }
        public string Log { get; set; }

        public void Refresh(Action<Job> callback, Action<Exception> error)
        {
            using (var api = new TravisAPI(auth_token, auth_token != null))
            {
                api.GetJob(this.Id, (o) => callback.Invoke((Job)o), error);
            }
        }
    }
}
